package com.dudy.domain;

import java.util.Comparator;

/**
 * @program: zhuguangDemo
 * @description: ${description}
 * @author: dudy
 * @create: 2018-04-03 17:48
 **/
public class User implements Comparator<User> ,Comparable<User>{
    @Override
    public int compare(User o1, User o2) {
        if (o1 == null || o2 == null) {
            return 0;
        }
        if (o1.getAge() == o2.getAge()) {
            return 0;
        }
        if (o1.getAge() > o2.getAge()) {
            return 1;
        }
        if (o1.getAge() < o2.getAge()) {
            return -1;
        }
        return 0;
    }

    @Override
    public int compareTo(User o) {
        if (this.id == o.getId()) {
            return 0;
        }
        if (this.id > o.getId()) {
            return 1;
        }
        if (this.id < o.getId()) {
            return -1;
        }
        return 0;
    }

    public User() {
    }

    public User(long id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public User(long id, String name, String pwd, String phone, String email, int age) {
        this.id = id;
        this.name = name;
        this.pwd = pwd;
        this.phone = phone;
        this.email = email;
        this.age = age;
    }

    private long id;
    private String name;
    private String pwd;
    private String phone;
    private String email;
    private int age;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
